<template>
  <!-- 运行分析 -->
	<view class="conter">
    <cc-goback title='运行分析' color="#fff"></cc-goback>
     <view class="navigation_head"></view>
      <view class="box_card">
        <view class="card_word">
          企业
        </view>
        <view class="head_a">
          <view class="head_word">
            <ms-dropdown-menu>
              <ms-dropdown-item @input="mileage" v-model="value" :list="All_enterpriseList"></ms-dropdown-item>
            </ms-dropdown-menu>
          </view>
        </view>
        <view class="card_word">
          数据时间
        </view>
        <view class="head">
              <view class="head_left">
              <uni-datetime-picker type="date" :value="date" start="2020-6-15" end="2025-6-15" @change="dateChange"></uni-datetime-picker>
              </view>
              <view class="head_left">
               <uni-datetime-picker type="date" :value="date" start="2020-6-15" end="2025-6-15" @change="dateChange_a"></uni-datetime-picker>
              </view>
        </view>
        <view class="btn" @click="setdata">
          查询数据
        </view>
      </view>
	</view>
</template>

<script>
	import msDropdownMenu from '@/components/ms-dropdown/dropdown-menu.vue'
	import msDropdownItem from '@/components/ms-dropdown/dropdown-item.vue'
	export default {
	  components: {
	    msDropdownMenu,
	    msDropdownItem
	  },
		data() {
			return {
        date:'',
				value: 0,
        startTime:'',
        endTime:'',
        All_enterpriseList: [],
        enterprise_id: '',
			};
		},
    onLoad() {
      this.getAllstate()
    },
    methods:{
      // 全部企业状态
      getAllstate() {
        this.$http.get('/envirnment-air/app/workStatistics/realWork', {}).then(res => {
          console.log('设备状态数量统计', res)
          if (res.code == '00000') {
            // console.log('设备状态数量统计', res.data)
            const list = []
            res.data.enterpriseCount.forEach((item, index) => {
              list.push({
                text: item.name,
                id: item.id,
                value: index + 1
              })
            })
            list.unshift({
              text: '请选择需要查询的企业',
              value: 0
            })
            this.All_enterpriseList = list
          }
        })
      },
      // 运行分析-全部设备查询
      getAll_equipment(){
        this.$http.get('/envirnment-air/app/workStatistics/runAnalysisEqu',{
           startTime:this.startTime,
           endTime:this.endTime,
           enterPriseId:this.enterprise_id
        }).then(res=>{
          if(res.code=='00000'){
            // console.log('res',res)
            uni.setStorageSync('equipmentList',res.data)
            uni.setStorageSync('startTime',this.startTime)
            uni.setStorageSync('endTime',this.endTime)
            uni.navigateTo({
            	url:'../operation_analysis_a/operation_analysis_a'
            })
          }
        })
      },
      setdata(){
        this.getAll_equipment()
       
      },
      dateChange(e){
       this.startTime = e
       // console.log('0000',this.startTime)
      },
      dateChange_a(e){
        this.endTime = e
        // console.log('0000',this.endTime)
      },
      mileage(e) {
        this.enterprise_id = e.id
        // console.log('enterprise_id',this.enterprise_id);
      },
    }
	}
</script>

<style lang="scss">
  .conter{
    height: 100vh;
    background-color: #F7F7F7;
    overflow: hidden;
  }
  .navigation_head{
    height: calc(88rpx + var(--status-bar-height));
  }
  .box_card{
    width: 662rpx;
    margin: 20rpx auto;
    border-radius: 8rpx;
    background-color: #FFFFFF;
    padding: 20rpx;
  }
  .head_a {
    width: 630rpx;
    height: 80rpx;
    margin: 20rpx auto;
    overflow: hidden;
    border-radius: 8rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    border: 1rpx solid #ccc;
  }
  .head{
    width: 630rpx;
    margin: 19rpx auto 0;
    display: flex;
    justify-content: space-around;
  }
  .head_left{
    width: 45%;
  }
  .card_word{
    font-size: 28rpx;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #333333;
  }
  .btn{
    margin: 87rpx auto 0;
    width: 630rpx;
    height: 80rpx;
    font-size: 28rpx;
    font-family: PingFang-SC-Medium, PingFang-SC;
    font-weight: 500;
    color: #FFFFFF;
    text-align: center;
    line-height: 80rpx;
    background: #4EA1FF;
    border-radius: 4rpx;
  }
</style>
